#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int b, c, d;
	double a;
	double qian;
	scanf("%lf %d %d %d", &a, &b, &c, &d);
	if ((11 == b && 11 == c) || (12 == b && 12 == c))
	{
		if (0 == d)
		{
			if (11 == b)
			{
				qian = a * 0.7;
			}
			if (12 == b)
			{
				qian = a * 0.8;
			}
		}
		if (1 == d)
		{
			if (11 == b)
			{
				qian = a * 0.7 - 50;
			}
			if (12 == b)
			{
				qian = a * 0.8 - 50;
			}
		}
	}
	qian = qian < 0 ? 0.00 : qian;
	printf("%.2lf", qian);
	return 0;
}

